<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=9">
<title>用户管理</title>

<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-switch.css">
<link rel="stylesheet" href="css/bootstrap-table.min.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap-switch.js"></script>
<script src="js/bootstrap-table.min.js"></script>
<script src="js/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript">
function actionFormatter(value, row, index) {
	if(value=='1'){
		return '<input type="checkbox" name="my-checkbox" uuid='+row.UUID+' checked>';
	}else{
		return '<input type="checkbox" name="my-checkbox" uuid='+row.UUID+' >';
	}
}
$(function(){
	$.ajax({  
		 url:'/controller?op=login&opid=userManager',// 跳转到 action   4     
		 type:'post', 
		 dataType:'json',  
		 async: false,
		 success:function(data) {  
			 $("#finishingTask").bootstrapTable('load',data.value);
			 
		 },  
		 error : function() {  
			 alert("获取数据异常！");  
		 }  
	});
	$("[name='my-checkbox']").bootstrapSwitch();
	$('input[name="my-checkbox"]').bootstrapSwitch('size', 'mini');
	$('input[name="my-checkbox"]').bootstrapSwitch('onColor', 'success');
	$('input[name="my-checkbox"]').bootstrapSwitch('offColor', 'danger');
	$('input[name="my-checkbox"]').bootstrapSwitch('onText', '启用');
	$('input[name="my-checkbox"]').bootstrapSwitch('offText', '停用');
	$('input[name="my-checkbox"]').on('switchChange.bootstrapSwitch', function(event, state) {
		var uuid = this.getAttribute('uuid');
		var flag = 0;
		if(state == true){
			flag = 1;
		}
		$.ajax({  
			 url:'/controller?op=login&opid=validate',// 跳转到 action   4     
			 data:{  
				 uuid : uuid,  
				 model : flag
			 },  
			 type:'post', 
			 dataType:'json',  
			 success:function(data) {  
			 },  
			 error : function() {  
				 alert("操作异常！");  
			 }  
		});
		  
	});
	
});

</script>
</head>
<body>

	<table id="finishingTask" data-toggle="table" data-height="500"
		data-striped="true">
		<thead>
			<tr>
				<th data-field="FIRM">公司</th>
				<th data-field="DEPARTMENT">部门</th>
				<th data-field="NAME">用户名</th>
				<th data-field="MODEL">手机型号</th>
				<th data-field="UUID">手机串号</th>
				<th data-field="RTIME">注册时间</th>
				<th data-field="FLAG" data-formatter="actionFormatter">状态</th>
			</tr>
		</thead>

	</table>

</body>
</html>